<template>
  <Form
    ref="personnelForm"
    :model="form"
    :rules="rules"
    inline
    @keydown.enter.native="handleSubmit"
    style="width: 100%">
    <FormItem prop="name" style="width: 15%">
      <Input type="text" v-model="form.name" placeholder="请输入应聘者姓名" />
    </FormItem>
    <FormItem prop="job" style="width: 15%">
      <Input type="text" v-model="form.job" placeholder="请输入应聘岗位" />
    </FormItem>
    <!-- <FormItem prop="muid" style="width: 15%">
      <Input type="text" v-model="form.muid" placeholder="请输入hrID" />
    </FormItem> -->
    <FormItem prop="state" style="width: 15%">
      <Select v-model="form.state" placeholder="请选择面试状态" clearable>
        <Option value="-1">
          预约未到
        </Option>
        <Option value="0">
          面试中
        </Option>
        <Option value="1">
          面试录用
        </Option>
        <Option value="2">
          面试不录用
        </Option>
      </Select>
    </FormItem>
    <FormItem prop="pcode" style="width: 15%">
      <Input type="text" v-model="form.pcode" placeholder="请输入渠道来源" />
      <!-- <Select v-model="form.pcode" placeholder="请选择渠道来源" clearable>
        <Option value=0>
          58同城
        </Option>
        <Option value=1>
          内部推荐
        </Option>
        <Option value=2>
          boss直聘
        </Option>
      </Select> -->
    </FormItem>
    <FormItem prop="isreview" style="width: 15%">
      <Select v-model="form.isreview" placeholder="请选择是否复试" clearable>
        <Option value="1">
          是
        </Option>
        <Option value="0">
          否
        </Option>
      </Select>
    </FormItem>
    <FormItem style="float: right">
      <Button @click="handleSubmit" icon="md-search" type="primary">
        搜索
      </Button>
    </FormItem>
  </Form>
</template>
<script>
export default {
  name: 'PersonnelForm',
  props: {
    nameRules: {
      type: Array,
      default: () => {
        return []
      }
    },
    jobRules: {
      type: Array,
      default: () => {
        return []
      }
    },
    stateRules: {
      type: Array,
      default: () => {
        return []
      }
    },
    pcodeRules: {
      type: Array,
      default: () => {
        return []
      }
    },
    isreviewRules: {
      type: Array,
      default: () => {
        return []
      }
    },
    viewresultRules: {
      type: Array,
      default: () => {
        return []
      }
    },
    reviewresultRules: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      form: {
        name: '',
        job: '',
        state: '',
        pcode: '',
        isreview: '',
        viewresult: '',
        reviewresult: ''
      }
    }
  },
  computed: {
    rules () {
      return {
        name: this.nameRules,
        job: this.jobRules,
        state: this.stateRules,
        pcode: this.pcodeRules,
        isreview: this.isreviewRules
      }
    }
  },
  methods: {
    handleSubmit () {
      this.$refs.personnelForm.validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            name: this.form.name,
            job: this.form.job,
            state: this.form.state ? parseInt(this.form.state) : '',
            pcode: this.form.pcode,
            isreview: this.form.isreview ? parseInt(this.form.isreview) : ''
          })
        }
      })
    }
  }
}
</script>
